package com.example.pet.controller;

import com.example.pet.service.FriendsRelService;
import com.hj.pet.model.FriendsRel;
import com.hj.pet.model.ReturnT;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/FR")
public class FriendsRelController {
    @Autowired
    FriendsRelService friendsRelService;

    @RequestMapping(value = "save",method = RequestMethod.POST)
    @ResponseBody
    public ReturnT<?> save(@RequestBody FriendsRel friendsRel){
        return friendsRelService.save(friendsRel);
    }

    @RequestMapping(value = "updateByUserId",method = RequestMethod.POST)
    @ResponseBody
    public ReturnT<?> updateByUserId(@RequestBody FriendsRel friendsRel){
        return friendsRelService.updateByUserId(friendsRel);
    }

    @RequestMapping(value = "findRelsByUser1",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> findRelsByUser1(@RequestParam String user_1){
        return friendsRelService.findRelsByUser1(user_1);
    }

    @RequestMapping(value = "findRelsByUser2",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> findRelsByUser2(@RequestParam String user_2){
        return friendsRelService.findRelsByUser2(user_2);
    }

    @RequestMapping(value = "delRelByUser",method = RequestMethod.DELETE)
    @ResponseBody
    public ReturnT<?> delRelByUser(@RequestParam String user_1,@RequestParam String user_2){
        return friendsRelService.delRelByUser(user_1, user_2);
    }

    @RequestMapping(value = "findRels",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> findRels(@RequestBody FriendsRel friendsRel){
        return friendsRelService.findRels(friendsRel);
    }

    @RequestMapping(value = "addFriendRequest",method = RequestMethod.POST)
    @ResponseBody
    public ReturnT<?> addFriendRequest(@RequestBody FriendsRel friendsRel){
        return friendsRelService.addFriendRequest(friendsRel);
    }

    @RequestMapping(value = "getDealingRels",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> getDealingRels(@RequestParam String user1){
        return friendsRelService.getDealingRels(user1);
    }

    @RequestMapping(value = "getDealingRels2",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> getDealingRels(@RequestParam String user1,@RequestParam Integer status){
        return friendsRelService.getDealingRels(user1, status);
    }

    @RequestMapping(value = "dealFriendRel",method = RequestMethod.POST)
    @ResponseBody
    public ReturnT<?> dealFriendRel(@RequestBody FriendsRel friendsRel){
        return friendsRelService.dealFriendRel(friendsRel);
    }

    @RequestMapping(value = "getAllFriends",method = RequestMethod.GET)
    @ResponseBody
    public ReturnT<?> getAllFriends(@RequestParam String user1){
        return friendsRelService.getAllFriends(user1);
    }
}
